#!/usr/bin/env python
# encoding: utf-8

"""
cwstats.py

Created by Aristide Grange on 2009-10-05.
"""

import re

def main(env):
	text = env["context"]["selection"]
	result = env["static"]["cwStats_format"] % {
		"lines": text.count("\n") + (0 if text.endswith("\n") else 1),
		"sentences": len(re.findall(env["constants"]["sentenceRex"],text)),
		"words": len(text.split()),
		"characters": len(text)
	}
	return [("tooltip",result),("moveCursor",0)]
